<div id="Accessing-branches"></div>
<div class="header">
<p>
Next: [[cvs: Branches and revisions#Branches and revisions|Branches and revisions]], Previous: [[cvs: Creating a branch#Creating a branch|Creating a branch]], Up: [[cvs: Branching and merging#Branching and merging|Branching and merging]] &nbsp; |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|</p>
</div>

----

<div id="Accessing-branches-1"></div>
=== Accessing branches ===
<div id="index-Check-out-a-branch"></div>
<div id="index-Retrieve-a-branch"></div>
<div id="index-Access-a-branch"></div>
<div id="index-Identifying-a-branch"></div>
<div id="index-Branch_002c-check-out"></div>
<div id="index-Branch_002c-retrieving"></div>
<div id="index-Branch_002c-accessing"></div>
<div id="index-Branch_002c-identifying"></div>

You can retrieve a branch in one of two ways: by
checking it out fresh from the repository, or by
switching an existing working copy over to the branch.

To check out a branch from the repository, invoke
&lsquo;<code>checkout</code>&rsquo; with the &lsquo;<code>-r</code>&rsquo; flag, followed by
the tag name of the branch (see [[cvs: Creating a branch#Creating a branch|Creating a branch]]):

<div class="example" style="margin-left: 3.2em">
 $ cvs checkout -r rel-1-0-patches tc
</div>

Or, if you already have a working copy, you can switch
it to a given branch with &lsquo;<code>update -r</code>&rsquo;:

<div class="example" style="margin-left: 3.2em">
 $ cvs update -r rel-1-0-patches tc
</div>

or equivalently:

<div class="example" style="margin-left: 3.2em">
 $ cd tc
 $ cvs update -r rel-1-0-patches
</div>

It does not matter if the working copy was originally
on the main trunk or on some other branch &ndash; the above
command will switch it to the named branch.  And
similarly to a regular &lsquo;<code>update</code>&rsquo; command,
&lsquo;<code>update -r</code>&rsquo; merges any changes you have made,
notifying you of conflicts where they occur.

Once you have a working copy tied to a particular
branch, it remains there until you tell it otherwise.
This means that changes checked in from the working
copy will add new revisions on that branch, while
leaving the main trunk and other branches unaffected.

<div id="index-Branches_002c-sticky"></div>
To find out what branch a working copy is on, you can
use the &lsquo;<code>status</code>&rsquo; command.  In its output, look for
the field named &lsquo;<code>Sticky tag</code>&rsquo; (see [[cvs: Sticky tags#Sticky tags|Sticky tags]])
&ndash; that&rsquo;s <small>CVS</small>&rsquo;s way of telling you the branch, if
any, of the current working files:

<div class="example" style="margin-left: 3.2em">
 $ cvs status -v driver.c backend.c
 ===================================================================
 File: driver.c          Status: Up-to-date
 
     Version:            1.7     Sat Dec  5 18:25:54 1992
     RCS Version:        1.7     /u/cvsroot/yoyodyne/tc/driver.c,v
     Sticky Tag:         rel-1-0-patches (branch: 1.7.2)
     Sticky Date:        (none)
     Sticky Options:     (none)
 
     Existing Tags:
         rel-1-0-patches             (branch: 1.7.2)
         rel-1-0                     (revision: 1.7)
 
 ===================================================================
 File: backend.c         Status: Up-to-date
 
     Version:            1.4     Tue Dec  1 14:39:01 1992
     RCS Version:        1.4     /u/cvsroot/yoyodyne/tc/backend.c,v
     Sticky Tag:         rel-1-0-patches (branch: 1.4.2)
     Sticky Date:        (none)
     Sticky Options:     (none)
 
     Existing Tags:
         rel-1-0-patches             (branch: 1.4.2)
         rel-1-0                     (revision: 1.4)
         rel-0-4                     (revision: 1.4)
 
</div>

Don&rsquo;t be confused by the fact that the branch numbers
for each file are different (&lsquo;<code>1.7.2</code>&rsquo; and
&lsquo;<code>1.4.2</code>&rsquo; respectively).  The branch tag is the
same, &lsquo;<code>rel-1-0-patches</code>&rsquo;, and the files are
indeed on the same branch.  The numbers simply reflect
the point in each file&rsquo;s revision history at which the
branch was made.  In the above example, one can deduce
that &lsquo;<code>driver.c</code>&rsquo; had been through more changes than
&lsquo;<code>backend.c</code>&rsquo; before this branch was created.

See [[cvs: Branches and revisions#Branches and revisions|Branches and revisions]] for details about how
branch numbers are constructed.


----

<div class="header">
<p>
Next: [[cvs: Branches and revisions#Branches and revisions|Branches and revisions]], Previous: [[cvs: Creating a branch#Creating a branch|Creating a branch]], Up: [[cvs: Branching and merging#Branching and merging|Branching and merging]] &nbsp; |[[cvs: Index#SEC_Contents|Contents]]||[[cvs: Index#Index|Index]]|</p>
</div>
This document was generated on <i>a sunny day</i> using [http://www.nongnu.org/texi2html/ <i>texi2html</i>].
